package com.zhao.service.serviceImpl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhao.mapper.CommentMapper;
import com.zhao.pojo.Comment;
import com.zhao.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class CommentServiceImpl extends ServiceImpl<CommentMapper, Comment> implements CommentService {
    @Autowired
    CommentMapper commentMapper;
    @Override
    public  List<Comment> commentSort(List<Comment> comments) {
        for (Comment comment:comments) {
            List<Comment> son = commentMapper.queryByFatherByArtid(null,comment.getId());
            comment.setSons(son);
        }
        return comments;
    }

    @Override
    public List<Comment> queryByFatherByArtid(Integer id, int i) {
        return commentMapper.queryByFatherByArtid(id,i);
    }

    @Override
    public List<Integer> queryAuthorByIds(String userAccount) {
        return commentMapper.queryAuthorByIds(userAccount);
    }
}
